/* name: graph
 * author: 5ab
 * created at: 2024-06-11
 */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))

auto chmax = [](auto& x, auto y) { if (x < y) x = y; };
auto chmin = [](auto& x, auto y) { if (y < x) x = y; };

using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
const int N = 2e5, M = 2e5, B = 64;

int hd[N], des[M * 2], nxt[M * 2], ec = 0;
bool vis[N];
vector<pair<int, int>> tr[N];
u64 rv[M], tv[N], bs[B];
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

void add(int s, int t)
{
	des[ec] = t;
	nxt[ec] = hd[s];
	hd[s] = ec++;
}

void dfs(int id, int fa)
{
	vis[id] = 1;
	for (int p = hd[id], dst; p != -1; p = nxt[p])
	{
		dst = des[p];
		if (!vis[dst])
		{
			tr[id].emplace_back(dst, p >> 1);
			dfs(dst, id);
		}
		else if (dst != fa && id < dst)
		{
			// cerr << id << " " << dst << endl;
			rv[p >> 1] = rng();
			tv[id] ^= rv[p >> 1], tv[dst] ^= rv[p >> 1];
		}
	}
}
void dfs2(int id)
{
	for (auto [x, p] : tr[id])
	{
		dfs2(x);
		rv[p] = tv[x];
		tv[id] ^= tv[x];
	}
}

signed main()
{
	freopen("graph.in", "r", stdin);
	freopen("graph.out", "w", stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m;
	
	cin >> n >> m;
	fill(hd, hd + n, -1);
	
	for (int i = 0, x, y; i < m; i++)
	{
		cin >> x >> y, x--, y--;
		add(x, y), add(y, x);
	}
	dfs(0, -1), dfs2(0);
	
	// for (int i = 0; i < m; i++)
	// 	cerr << rv[i] << endl;
	
	int q, k, x;
	
	cin >> q;
	while (q--)
	{
		cin >> k;
		bool ok = 1;
		fill(bs, bs + B, 0);
		for (int i = 0; i < k; i++)
		{
			cin >> x, x--;
			auto cv = rv[x];
			for (int j = B - 1; j >= 0; j--) if ((cv >> j) & 1)
			{
				if (!bs[j])
				{
					bs[j] = cv;
					break;
				}
				cv ^= bs[j];
			}
			// cerr << cv << endl;
			if (!cv)
				ok = 0;
		}
		cout << (ok ? "YES" : "NO") << "\n";
	}
	
	return 0;
}
// started coding at: 06-11 11:14:42